$(document).ready(function(){
  car = {};
  carousel = $('#cvr_hpslideshow');
  car.pitems = carousel.find('.pager li');
  car.imgs = carousel.find('#hpslideshow li')
  car.current = 0;
  
  ticker = setTimeout(tick, 5000);
  
  car.pitems.click(function(){
    e = parseInt($(this).attr('rel'));
    showthis(e);
    
    return false;
  });
  function tick(){
    if ((car.current+1) < car.pitems.length) {car.current += 1;}
    else {car.current = 0;}
    showthis(car.current);
  }
  function showthis(e) {
    clearTimeout(ticker);
    car.current = e;
    car.pitems.removeClass('active').eq(e).addClass('active');
    car.imgs.fadeOut().eq(e).fadeIn();
    ticker = setTimeout(tick, 5000);
  }
});